#include<bits/stdc++.h>
using namespace std;
#define  int long long
int n,q;
const int p = 1145141;
const int MAXN = 1e6+10;
int a[MAXN];

//费马小定理
template<typename T> T fast_pow(T base, T exponent, T modulus) {
    T result = 1;
    while (exponent > 0) {
        if (exponent & 1) result = (result * base) % modulus;
        base = (base * base) % modulus;
        exponent >>= 1;
    }
    return result;
}
int inv(int x){ //费马小定理
    int res = fast_pow(x,p-2,p);
    return res;
}
signed  main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    cin >> n >> q;
    a[0] = 1;
    for(int i = 1 ; i <= n ; i ++) {cin >> a[i];a[i] %= p;}
    for(int i = 1 ; i <= n ; i ++){a[i] *= a[i-1];a[i] %= p;}
    int ans = 0;
    while(q -- ){
        int l , r;
        cin >> l >> r;
        int tmp = a[r] * inv(a[l-1]) %p;
        ans ^= tmp;
    }
    cout << ans;
    return 0;
}
